package com.burgeon.backend.SHOPBACKEND.rest;

import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

/**
 * 修改同步状态
 */
public class UpdateYCIsTs extends RESTBase {
    private String ip;
    private String account;
    private String password;

    public UpdateYCIsTs(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public Integer getData(String id) throws Exception {
        String url = "http://" + ip + "/servlets/binserv/Rest";
        String str = RESULT(Data(id), url);
        //System.err.println(str);
        String code = new JSONArray(str).getJSONObject(0).getString("code");
        if (!"0".equals(code)) {
            throw new Exception(str);
        }
        return null;

    }

    private MultiValueMap Data(String id) {

        HashMap params = new HashMap();

        params.put("ID", id);
        params.put("partial_update", "true");
        params.put("table", "YC_RETAILOUT");//表名

        params.put("IS_TS", "Y");
        //System.err.println(params);

        return DATA("ObjectModify", params, account, password);
    }

    public static void main(String[] args) {
        UpdateYCIsTs g = new UpdateYCIsTs("39.99.239.133:55322", "nea@burgeon.com.cn", "mgg55321");
        try {

            System.err.println(g.getData("43"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
